# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# PINS test functions that can be run on any infrastructure that supports ThinKit.

load("@com_google_googleapis_imports//:imports.bzl", "cc_proto_library")

package(
    default_visibility = ["//visibility:public"],
    licenses = ["notice"],
)

cc_library(
    name = "gnmi_helper",
    srcs = ["gnmi_helper.cc"],
    hdrs = ["gnmi_helper.h"],
    deps = [
        ":openconfig_cc_proto",
        "//gutil/gutil:collections",
        "//gutil/gutil:proto",
        "//gutil/gutil:status",
        "//lib/p4rt:p4rt_port",
        "//lib/utils:json_utils",
        "//p4_pdpi:p4_runtime_session",
        "//thinkit:switch",
        "@com_github_gnmi//proto/gnmi:gnmi_cc_grpc_proto",
        "@com_github_gnmi//proto/gnmi:gnmi_cc_proto",
        "@com_github_gnmi//proto/gnmi_ext:gnmi_ext_cc_proto",
        "@com_github_gnoi//types:types_cc_proto",
        "@com_github_google_glog//:glog",
        "@com_github_grpc_grpc//:grpc++",
        "@com_github_nlohmann_json//:nlohmann_json",
        "@com_google_absl//absl/algorithm:container",
        "@com_google_absl//absl/container:btree",
        "@com_google_absl//absl/container:flat_hash_map",
        "@com_google_absl//absl/container:flat_hash_set",
        "@com_google_absl//absl/functional:any_invocable",
        "@com_google_absl//absl/numeric:int128",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/strings:str_format",
        "@com_google_absl//absl/time",
        "@com_google_absl//absl/types:span",
        "@com_google_protobuf//:protobuf",
        "@com_googlesource_code_re2//:re2",
        "@com_jsoncpp//:json",
    ],
)

cc_test(
    name = "gnmi_helper_test",
    srcs = ["gnmi_helper_test.cc"],
    deps = [
        ":gnmi_helper",
        ":openconfig_cc_proto",
        "//gutil/gutil:proto_matchers",
        "//gutil/gutil:status_matchers",
        "//gutil/gutil:testing",
        "@com_github_gnmi//proto/gnmi:gnmi_cc_grpc_proto",
        "@com_github_gnmi//proto/gnmi:gnmi_cc_proto",
        "@com_github_gnoi//types:types_cc_proto",
        "@com_github_google_glog//:glog",
        "@com_github_grpc_grpc//:grpc++",
        "@com_github_nlohmann_json//:nlohmann_json",
        "@com_google_absl//absl/container:btree",
        "@com_google_absl//absl/container:flat_hash_map",
        "@com_google_absl//absl/container:flat_hash_set",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/strings:str_format",
        "@com_google_absl//absl/time",
        "@com_google_absl//absl/types:span",
        "@com_google_googletest//:gtest_main",
        "@com_google_protobuf//:protobuf",
    ],
)

proto_library(
    name = "openconfig_proto",
    srcs = ["openconfig.proto"],
)

cc_proto_library(
    name = "openconfig_cc_proto",
    deps = [":openconfig_proto"],
)
